package com.cr.front.city.controller;

import com.cr.common.response.JsonResult;
import com.cr.front.city.pojo.query.CarRentalCityQuery;
import com.cr.front.city.pojo.vo.CarRentalCityVO;
import com.cr.front.city.pojo.vo.CityIndexVO;
import com.cr.front.city.service.CarRentalCityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@Api(tags = "租车城市")
@RequestMapping("/city")
public class CarRentalCityController {

    @Autowired
    private CarRentalCityService carRentalCityService;

    @GetMapping("selectHotCityList")
    @ApiOperation(value = "查找热门城市")
    public JsonResult selectHotCityList() {
        List<CarRentalCityVO> list = carRentalCityService.selectHotCityList();
        return JsonResult.success(list);
    }
    @GetMapping("selectHotCityList2")
    @ApiOperation(value = "查找热租城市")
    public JsonResult selectHotCityList2() {
        List<CarRentalCityVO> list2 = carRentalCityService.selectHotCityList2();
        return JsonResult.success(list2);
    }

    @GetMapping("/selectLetterCityList")
    @ApiOperation(value = "根据字母查城市")
    public JsonResult selectLetterCityList(){
        Map<Character,List<CityIndexVO>> map =  carRentalCityService.selectLetterCityList();
        return JsonResult.success(map);
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查找城市")
    public JsonResult selectCityById(@PathVariable Long id){
        CarRentalCityVO carRentalCityVO = carRentalCityService.selectById(id);
        return JsonResult.success(carRentalCityVO);
    }
}
